//https://autumnfish.cn/search keywords 音乐搜索
//https://autumnfish.cn/song/url 歌曲url获取 请求参数id
//https://autumnfish.cn/song/detail 请求参数ids(歌曲id)
//https://autumnfish.cn/comment/hot?type=0 请求参数id(歌曲id) 获取评论数据type写死为0
//https://autumnfish.cn/mv/url 请求参数id(mvid,为0说明没有mv)，获取mv的地址


var app = new Vue({
    el: '#player',
    data: {
        music: '',
        musicList: [],
        playMusicSrc: '',
        playMusicCover: "",
        isPlaying: false,
        comments: [],
        isShowMv: false,
        mvSrc: ''
    },
    methods: {
        // 音乐搜索
        searchMusic: function () {
            if (this.music.length === 0) {
                return;
            }
            var that = this;
            axios.get("https://autumnfish.cn/search?keywords=" + this.music).then(function (response) {
                that.musicList = response.data.result.songs;
            }, function (err) { })
        },
        //播放音乐
        playMusic: function (musicId) {
            var that = this;
            axios.get("https://autumnfish.cn/song/url?id=" + musicId).then(function (response) {
                that.playMusicSrc = response.data.data[0].url;
            }, function (error) { });
            //请求歌曲详细信息
            axios.get("https://autumnfish.cn/song/detail?ids=" + musicId).then(function (response) {
                that.playMusicCover = response.data.songs[0].al.picUrl;
            }, function (error) { });

            axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId).then(function (response) {
                console.log(response);
                that.comments = response.data.hotComments;
            }, function (error) { });

        },
        play: function () {
            console.log('播放');
            this.isPlaying = true;
        },
        pause: function () {
            console.log('暂停');
            this.isPlaying = false;
        },
        hideMv: function () {
            //document.querySelector("video").pause();
            this.isShowMv = false;
        },
        showMv: function (mvid) {
            var that = this;
            document.querySelector("audio").pause();
            axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(function (response) {
                console.log(response.data.data.url);
                that.isShowMv = true;
                that.mvSrc = response.data.data.url;
            }, function (error) { })

        }


    }


})